import $api from './index';

interface  companyData  {
  name: string,
  isVue: number,
  isReact: number,
  areaid: string,
  desc?: string,
  skill?: string
}
export default null;

/*
 author: dixon
 date: 20220923
 name: 添加公司
*/
export const addCompany = async  (data: companyData) => {
  const res = await $api.post('/company', data);
  return res;
};

/*
 author: dixon
 date: 20220923
 name: 修改公司信息
*/
export const editCompany = async  (data: companyData, id: string) => {
  const res = await $api.put(`/company/${id}`, data);
  return res;
};

/*
 author: dixon
 date: 20220923
 name: 获取公司列表
*/
export const getCompanyList = async ({
  $limit = 10,
  $skip = 0,
  isVue = false,
  isReact = false,
}) => {
  const hasVue = isVue ? '&isVue=1' : '';
  const hasReact = isReact ? '&isReact=1' : '';
  const res = await $api.get(`/company?$limit=${$limit}&$skip=${$skip}${hasVue}${hasReact}`);
  return res;
};

/*
 author: dixon
 date: 20220923
 name: 根据一个id来删除公司信息
*/
export const delCompany = async (id:string|number) => {
  const res = await $api.delete(`/company/${id}`);
  return res;
};
